package cn.bdqn.mh.mapper;

import cn.bdqn.mh.pojo.Ad;
import cn.bdqn.mh.pojo.Article;
import cn.bdqn.mh.pojo.House;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;
import org.springframework.web.servlet.tags.form.SelectTag;

import javax.xml.crypto.Data;
import java.util.List;

@Mapper
public interface HouseMapper {
    //SELECT houseImg,money,createHouseShop,housetypeId,title,housedesc FROM tbhouse ORDER BY createDate DESC
    @Select("SELECT houseImg,money,createHouseShop,housetypeId,title,housedesc FROM tbhouse ORDER BY createDate DESC")
    public List<House> getListGoodHouse();

    //SELECT houseImg,money,createHouseShop,housetypeId,title,housedesc FROM tbhouse ORDER BY clicks DESC
    @Select("SELECT houseImg,money,createHouseShop,housetypeId,title,housedesc FROM tbhouse ORDER BY clicks DESC")
    public List<House> getListClicks();

    //SELECT houseImg,money,createHouseShop,housetypeId,title,housedesc FROM tbhouse WHERE isMetroLine=1
    @Select("SELECT houseImg,money,createHouseShop,housetypeId,title,housedesc FROM tbhouse WHERE isMetroLine=1")
    public List<House> getListIsMetroLine();

    //SELECT houseImg,money,createHouseShop,housetypeId,title,housedesc FROM tbhouse ORDER BY money
    @Select("SELECT houseImg,money,createHouseShop,housetypeId,title,housedesc FROM tbhouse ORDER BY money")
    public List<House> getListByMoney();

    //SELECT houseImg,money,createHouseShop,housetypeId,title,housedesc FROM tbhouse WHERE houseTypeId IN
    // (SELECT id FROM tbhousetype WHERE NAME='一室一厅')
    @Select("SELECT houseImg,money,createHouseShop,housetypeId,title,housedesc FROM tbhouse WHERE houseTypeId IN(SELECT id FROM tbhousetype WHERE NAME='一室一厅')")
    public List<House> getListByHouseType();

    //SELECT houseImg,money,createHouseShop,housetypeId,title,housedesc FROM tbhouse WHERE title LIKE '%hh%' OR housedesc LIKE '%大道%'
    @Select("SELECT houseImg,money,createHouseShop,housetypeId,title,housedesc FROM tbhouse \n" +
            "WHERE title LIKE CONCAT('%',#{title},'%') OR housedesc LIKE CONCAT('%',#{title},'%')")
    public List<House> search(String title);

    //SELECT houseImg,saleMoney FROM tbhouse ORDER BY characteristicHouse DESC LIMIT 5
    @Select("SELECT houseImg,saleMoney FROM tbhouse ORDER BY characteristicHouse DESC LIMIT 5")
    public List<House> getSaleMoney();

}
